<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});


//小程序登录接口
Route::post('/xcx/getsession', 'UserCenterController@getSessionKey');
Route::post('/xcx/setlogin', 'UserCenterController@setLogin');
Route::post('/xcx/accesstoken', 'UserCenterController@getAccessToken');

//发送验证码
Route::any('send_verify_code','UsersController@sendVerifyCode');
Route::any('user_register','UsersController@register');
Route::any('find_password','UsersController@findPassword');
Route::any('edit_password','UsersController@passwordUpdate');
Route::any('user_login','UsersController@login');

//收藏

//购物车

Route::any('configs_by_group/{group}', 'ConfigAPIController@getConfigsByGroup');
Route::resource('articles', 'ArticlesAPIController');
Route::resource('colors', 'ColorsAPIController');
Route::resource('index_slideshows', 'IndexSlideshowsAPIController');
Route::resource('new_developments', 'NewDevelopmentsAPIController');

Route::get('goods/{id}', 'GoodsAPIController@show');
Route::get('new_development_types', 'NewDevelopmentTypesAPIController@index');
Route::middleware('xcx.checklogin')->group(function () {

    Route::get('goods', 'GoodsAPIController@index');
    Route::get('customer','UsersController@customerIndex');
    Route::get('customer/{id}','UsersController@customerInfo');
    Route::post('customer','UsersController@customerAdd');
    Route::any('customer_del/{id}','UsersController@customerDel');
    Route::post('customer/{id}','UsersController@customerUpdate');

    Route::post('set_cart','UsersController@setCart');
    Route::get('carts','CartsAPIController@index');
    Route::resource('orders', 'OrdersAPIController');
    Route::get('categories','ConfigAPIController@cateIndex');
    Route::get('labels','ConfigAPIController@labelIndex');
    Route::post('add_cart','UsersController@addCart');
    Route::post('un_like','UsersController@unLikeGoods');
    Route::post('like','UsersController@likeGoods');
    Route::post('/xcx/upload', 'PicturesController@upload');
    Route::post('/upload/avatar', 'PicturesController@uploadAvatar');
    Route::post('/xcx/get-qiniu-token', 'PicturesController@getQiniuToken');

    //用户信息
    Route::get('userinfo','UsersController@userInfo');
    Route::post('userinfo','UsersController@setInfo');
    Route::resource('configs', 'ConfigAPIController');
});

Route::any('pipe/post','UtilController@pipePost');

Route::post('/admin/edit_password', 'UsersController@adminEditPassword');